package com.secf.service.port.hpy.hys.test.day5;

/**
 * @Author luoYong
 * @Date 2024-08-13 17:41
 */
import java.util.Arrays;

public class StudentScoresManager {
    public static void main(String[] args) {
        int[] scores = {85, 92, 78, 96, 88, 73, 95};

        double average = calculateAverage(scores);
        System.out.println("Average Score: " + average);

        int maxScore = findMax(scores);
        int minScore = findMin(scores);
        System.out.println("Highest Score: " + maxScore);
        System.out.println("Lowest Score: " + minScore);

        Arrays.sort(scores);
        System.out.println("Sorted Scores: " + Arrays.toString(scores));
    }

    public static double calculateAverage(int[] scores) {
        int sum = 0;
        for (int score : scores) {
            sum += score;
        }
        return (double) sum / scores.length;
    }

    public static int findMax(int[] scores) {
        int max = scores[0];
        for (int score : scores) {
            if (score > max) {
                max = score;
            }
        }
        return max;
    }

    public static int findMin(int[] scores) {
        int min = scores[0];
        for (int score : scores) {
            if (score < min) {
                min = score;
            }
        }
        return min;
    }
}
